// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyavtCurveMetaData.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PyavtCurveMetaData
//
// Purpose:
//   Contains curve metadata attributes
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a avtCurveMetaData.
//
struct avtCurveMetaDataObject
{
    PyObject_HEAD
    avtCurveMetaData *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewavtCurveMetaData(int);
std::string
PyavtCurveMetaData_ToString(const avtCurveMetaData *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    str = PyavtVarMetaData_ToString(atts, prefix, forLogging);

    snprintf(tmpStr, 1000, "%sxUnits = \"%s\"\n", prefix, atts->xUnits.c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sxLabel = \"%s\"\n", prefix, atts->xLabel.c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%syUnits = \"%s\"\n", prefix, atts->yUnits.c_str());
    str += tmpStr;
    snprintf(tmpStr, 1000, "%syLabel = \"%s\"\n", prefix, atts->yLabel.c_str());
    str += tmpStr;
    if(atts->hasSpatialExtents)
        snprintf(tmpStr, 1000, "%shasSpatialExtents = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%shasSpatialExtents = 0\n", prefix);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sminSpatialExtents = %g\n", prefix, atts->minSpatialExtents);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%smaxSpatialExtents = %g\n", prefix, atts->maxSpatialExtents);
    str += tmpStr;
    snprintf(tmpStr, 1000, "%sfrom1DScalarName = \"%s\"\n", prefix, atts->from1DScalarName.c_str());
    str += tmpStr;
    return str;
}

static PyObject *
avtCurveMetaData_Notify(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_SetXUnits(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the xUnits in the object.
    obj->data->xUnits = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetXUnits(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyString_FromString(obj->data->xUnits.c_str());
    return retval;
}

/*static*/ PyObject *
avtCurveMetaData_SetXLabel(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the xLabel in the object.
    obj->data->xLabel = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetXLabel(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyString_FromString(obj->data->xLabel.c_str());
    return retval;
}

/*static*/ PyObject *
avtCurveMetaData_SetYUnits(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the yUnits in the object.
    obj->data->yUnits = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetYUnits(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyString_FromString(obj->data->yUnits.c_str());
    return retval;
}

/*static*/ PyObject *
avtCurveMetaData_SetYLabel(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the yLabel in the object.
    obj->data->yLabel = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetYLabel(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyString_FromString(obj->data->yLabel.c_str());
    return retval;
}

/*static*/ PyObject *
avtCurveMetaData_SetHasSpatialExtents(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the hasSpatialExtents in the object.
    obj->data->hasSpatialExtents = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetHasSpatialExtents(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->hasSpatialExtents?1L:0L);
    return retval;
}

/*static*/ PyObject *
avtCurveMetaData_SetMinSpatialExtents(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the minSpatialExtents in the object.
    obj->data->minSpatialExtents = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetMinSpatialExtents(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->minSpatialExtents);
    return retval;
}

/*static*/ PyObject *
avtCurveMetaData_SetMaxSpatialExtents(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    double val = PyFloat_AsDouble(args);
    double cval = double(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ double");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(double(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ double");
    }

    Py_XDECREF(packaged_args);

    // Set the maxSpatialExtents in the object.
    obj->data->maxSpatialExtents = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetMaxSpatialExtents(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyFloat_FromDouble(obj->data->maxSpatialExtents);
    return retval;
}

/*static*/ PyObject *
avtCurveMetaData_SetFrom1DScalarName(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged as first member of a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyUnicode_Check(packaged_args))
            args = packaged_args;
    }

    if (!PyUnicode_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a unicode string");
    }

    char const *val = PyUnicode_AsUTF8(args);
    std::string cval = std::string(val);

    if (val == 0 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as utf8 string");
    }

    Py_XDECREF(packaged_args);

    // Set the from1DScalarName in the object.
    obj->data->from1DScalarName = cval;

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
avtCurveMetaData_GetFrom1DScalarName(PyObject *self, PyObject *args)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)self;
    PyObject *retval = PyString_FromString(obj->data->from1DScalarName.c_str());
    return retval;
}



PyMethodDef PyavtCurveMetaData_methods[AVTCURVEMETADATA_NMETH] = {
    {"Notify", avtCurveMetaData_Notify, METH_VARARGS},
    {"SetXUnits", avtCurveMetaData_SetXUnits, METH_VARARGS},
    {"GetXUnits", avtCurveMetaData_GetXUnits, METH_VARARGS},
    {"SetXLabel", avtCurveMetaData_SetXLabel, METH_VARARGS},
    {"GetXLabel", avtCurveMetaData_GetXLabel, METH_VARARGS},
    {"SetYUnits", avtCurveMetaData_SetYUnits, METH_VARARGS},
    {"GetYUnits", avtCurveMetaData_GetYUnits, METH_VARARGS},
    {"SetYLabel", avtCurveMetaData_SetYLabel, METH_VARARGS},
    {"GetYLabel", avtCurveMetaData_GetYLabel, METH_VARARGS},
    {"SetHasSpatialExtents", avtCurveMetaData_SetHasSpatialExtents, METH_VARARGS},
    {"GetHasSpatialExtents", avtCurveMetaData_GetHasSpatialExtents, METH_VARARGS},
    {"SetMinSpatialExtents", avtCurveMetaData_SetMinSpatialExtents, METH_VARARGS},
    {"GetMinSpatialExtents", avtCurveMetaData_GetMinSpatialExtents, METH_VARARGS},
    {"SetMaxSpatialExtents", avtCurveMetaData_SetMaxSpatialExtents, METH_VARARGS},
    {"GetMaxSpatialExtents", avtCurveMetaData_GetMaxSpatialExtents, METH_VARARGS},
    {"SetFrom1DScalarName", avtCurveMetaData_SetFrom1DScalarName, METH_VARARGS},
    {"GetFrom1DScalarName", avtCurveMetaData_GetFrom1DScalarName, METH_VARARGS},
    {NULL, NULL}
};

static void PyavtCurveMetaData_ExtendSetGetMethodTable()
{
    static bool extended = false;
    if (extended) return;
    extended = true;

    int i = 0;
    while (PyavtCurveMetaData_methods[i].ml_name)
        i++;
    int n = i;
    while (PyavtVarMetaData_methods[i-n+1].ml_name)
    {
        PyavtCurveMetaData_methods[i] = PyavtVarMetaData_methods[i-n+1];
        i++;
    }

    PyMethodDef nullMethod = {NULL, NULL};
    PyavtCurveMetaData_methods[i] = nullMethod;
}

//
// Type functions
//

static void
avtCurveMetaData_dealloc(PyObject *v)
{
   avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *avtCurveMetaData_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyavtCurveMetaData_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "xUnits") == 0)
        return avtCurveMetaData_GetXUnits(self, NULL);
    if(strcmp(name, "xLabel") == 0)
        return avtCurveMetaData_GetXLabel(self, NULL);
    if(strcmp(name, "yUnits") == 0)
        return avtCurveMetaData_GetYUnits(self, NULL);
    if(strcmp(name, "yLabel") == 0)
        return avtCurveMetaData_GetYLabel(self, NULL);
    if(strcmp(name, "hasSpatialExtents") == 0)
        return avtCurveMetaData_GetHasSpatialExtents(self, NULL);
    if(strcmp(name, "minSpatialExtents") == 0)
        return avtCurveMetaData_GetMinSpatialExtents(self, NULL);
    if(strcmp(name, "maxSpatialExtents") == 0)
        return avtCurveMetaData_GetMaxSpatialExtents(self, NULL);
    if(strcmp(name, "from1DScalarName") == 0)
        return avtCurveMetaData_GetFrom1DScalarName(self, NULL);

    if(strcmp(name, "__methods__") != 0)
    {
        PyObject *retval = PyavtVarMetaData_getattr(self, name);
        if (retval) return retval;
    }

    PyavtCurveMetaData_ExtendSetGetMethodTable();

    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyavtCurveMetaData_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyavtCurveMetaData_methods[i].ml_name),
                PyString_FromString(PyavtCurveMetaData_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyavtCurveMetaData_methods, self, name);
}

int
PyavtCurveMetaData_setattr(PyObject *self, char *name, PyObject *args)
{
    if (PyavtVarMetaData_setattr(self, name, args) != -1)
        return 0;
    else
        PyErr_Clear();

    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "xUnits") == 0)
        obj = avtCurveMetaData_SetXUnits(self, args);
    else if(strcmp(name, "xLabel") == 0)
        obj = avtCurveMetaData_SetXLabel(self, args);
    else if(strcmp(name, "yUnits") == 0)
        obj = avtCurveMetaData_SetYUnits(self, args);
    else if(strcmp(name, "yLabel") == 0)
        obj = avtCurveMetaData_SetYLabel(self, args);
    else if(strcmp(name, "hasSpatialExtents") == 0)
        obj = avtCurveMetaData_SetHasSpatialExtents(self, args);
    else if(strcmp(name, "minSpatialExtents") == 0)
        obj = avtCurveMetaData_SetMinSpatialExtents(self, args);
    else if(strcmp(name, "maxSpatialExtents") == 0)
        obj = avtCurveMetaData_SetMaxSpatialExtents(self, args);
    else if(strcmp(name, "from1DScalarName") == 0)
        obj = avtCurveMetaData_SetFrom1DScalarName(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
avtCurveMetaData_print(PyObject *v, FILE *fp, int flags)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)v;
    fprintf(fp, "%s", PyavtCurveMetaData_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
avtCurveMetaData_str(PyObject *v)
{
    avtCurveMetaDataObject *obj = (avtCurveMetaDataObject *)v;
    return PyString_FromString(PyavtCurveMetaData_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *avtCurveMetaData_Purpose = "Contains curve metadata attributes";
#else
static char *avtCurveMetaData_Purpose = "Contains curve metadata attributes";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(avtCurveMetaDataType,         \
                  "avtCurveMetaData",           \
                  avtCurveMetaDataObject,       \
                  avtCurveMetaData_dealloc,     \
                  avtCurveMetaData_print,       \
                  PyavtCurveMetaData_getattr,   \
                  PyavtCurveMetaData_setattr,   \
                  avtCurveMetaData_str,         \
                  avtCurveMetaData_Purpose,     \
                  avtCurveMetaData_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
avtCurveMetaData_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &avtCurveMetaDataType
         || Py_TYPE(other) != &avtCurveMetaDataType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    avtCurveMetaData *a = ((avtCurveMetaDataObject *)self)->data;
    avtCurveMetaData *b = ((avtCurveMetaDataObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static avtCurveMetaData *defaultAtts = 0;
static avtCurveMetaData *currentAtts = 0;

static PyObject *
NewavtCurveMetaData(int useCurrent)
{
    avtCurveMetaDataObject *newObject;
    newObject = PyObject_NEW(avtCurveMetaDataObject, &avtCurveMetaDataType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new avtCurveMetaData(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new avtCurveMetaData(*defaultAtts);
    else
        newObject->data = new avtCurveMetaData;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapavtCurveMetaData(const avtCurveMetaData *attr)
{
    avtCurveMetaDataObject *newObject;
    newObject = PyObject_NEW(avtCurveMetaDataObject, &avtCurveMetaDataType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (avtCurveMetaData *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
avtCurveMetaData_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewavtCurveMetaData(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef avtCurveMetaDataMethods[] = {
    {"avtCurveMetaData", avtCurveMetaData_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *avtCurveMetaDataObserver = 0;

std::string
PyavtCurveMetaData_GetLogString()
{
    std::string s("avtCurveMetaData = avtCurveMetaData()\n");
    if(currentAtts != 0)
        s += PyavtCurveMetaData_ToString(currentAtts, "avtCurveMetaData.", true);
    return s;
}

static void
PyavtCurveMetaData_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("avtCurveMetaData = avtCurveMetaData()\n");
        s += PyavtCurveMetaData_ToString(currentAtts, "avtCurveMetaData.", true);
        cb(s);
    }
}

void
PyavtCurveMetaData_StartUp(avtCurveMetaData *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyavtCurveMetaData_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(avtCurveMetaDataObserver == 0)
    {
        avtCurveMetaDataObserver = new ObserverToCallback(subj,
            PyavtCurveMetaData_CallLogRoutine, (void *)data);
    }

}

void
PyavtCurveMetaData_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete avtCurveMetaDataObserver;
    avtCurveMetaDataObserver = 0;
}

PyMethodDef *
PyavtCurveMetaData_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return avtCurveMetaDataMethods;
}

bool
PyavtCurveMetaData_Check(PyObject *obj)
{
    return (obj->ob_type == &avtCurveMetaDataType);
}

avtCurveMetaData *
PyavtCurveMetaData_FromPyObject(PyObject *obj)
{
    avtCurveMetaDataObject *obj2 = (avtCurveMetaDataObject *)obj;
    return obj2->data;
}

PyObject *
PyavtCurveMetaData_New()
{
    return NewavtCurveMetaData(0);
}

PyObject *
PyavtCurveMetaData_Wrap(const avtCurveMetaData *attr)
{
    return WrapavtCurveMetaData(attr);
}

void
PyavtCurveMetaData_SetParent(PyObject *obj, PyObject *parent)
{
    avtCurveMetaDataObject *obj2 = (avtCurveMetaDataObject *)obj;
    obj2->parent = parent;
}

void
PyavtCurveMetaData_SetDefaults(const avtCurveMetaData *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new avtCurveMetaData(*atts);
}

